import { getStorage, setStorage, } from '@/utils/storage';
import { reqLogin } from '@/api/login';

export const goToLogin = async () => {
  // 如果登录了 需要跳转我的详情页面
  const token = getStorage('token') || ''
  const isLogin = !!token;
  if (isLogin) {
    wx.navigateTo({
      url: '../../pages/setting/setting',
    })
  } else {
    // 如果没有登录 需要点击登录
    const loginRes = await wx.wxLogin();
    const { data } = await reqLogin(loginRes.code);
    setStorage('token', data)
  }
}

// 判断是否显示购物车
export const showCart = (cartList) => {
  if (cartList.length > 0) {
    return true
  }
  return false;
}